// 引入等比适配插件
const px2rem = require("postcss-px2rem");
const path = require('path')
function resolve(dir) {
  return path.join(__dirname, dir)
}
// 配置基本大小
const postcss = px2rem({
  // 基准大小 baseSize，需要和rem.js中相同
  remUnit: 16,
});

module.exports = {
  css: {
    loaderOptions: {
      less: {
        javascriptEnabled: true,
      },
      postcss: {
        plugins: [postcss],
      },
    },
  },
  publicPath: "/",
  outputDir: "dist",
  assetsDir: "static",
  lintOnSave: process.env.NODE_ENV === "development",
  productionSourceMap: false,
  devServer: {
    open: true,
    overlay: {
      warnings: false,
      errors: false,
    },
    proxy: {
      // "/": {
      //   target: "http://10.189.88.100:8888/",
      //   changeOrigin: true,
      //   pathRewrite: {
      //     "^/api": "/",
      //   },
      // },
      '/api': {
        target: "http://10.189.88.128:8001",
        changeOrigin: true,
        pathRewrite: {
          '^/api': 'api'
        }
      },
      '/semiApi': {
        target: "http://10.189.88.128:8001",
        changeOrigin: true,
        pathRewrite: {
          '^/api': 'api'
        }
      }
    },
  },
  chainWebpack(config) {
    config.module
      .rule('svg')
      .exclude.add(resolve('src/assets/icons'))
      .end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/assets/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end()
  }
};
